package parser

import (
	"go-learning-process/crawler/engine"
	"regexp"
)

const (
	// <a href="http://album.zhenai.com/u/1195899308" target="_blank">唯一</a>
	//cityRe = `<a href="(http://album.zhenai.com/u/[0-9]+ )"[^>]*>([^<] )</a>`
	homeRe = `<a target="_blank" href="(http://www.7btjia.com/thread-index-fid-1-tid-[0-9]+.htm)" [^>]*>[^<]+</a>`
)

func ParseList(contents []byte) engine.ParseResult {
	re := regexp.MustCompile(homeRe)
	matches := re.FindAllSubmatch(contents, -1)
	result := engine.ParseResult{}

	for _, m := range matches {
		//result.Items = append(result.Items, "User "+string(m[2]))
		result.Requests = append(result.Requests,
			engine.Request{
				Url:        string(m[1]),
				ParserFunc: GetContent,
			})
	}

	return result
}
